/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package STUDENT.NGUYENSANG.OOPs.QuanLiThuVien;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/**
 *
 * @author NSPDL
 */
public class NhapSach {
    public static List<Sach> ListSach=new ArrayList<>();
    public Sach newS()
    {
        Scanner input=new Scanner(System.in);
        Sach s=null;
        try{
            System.out.println("Nhap ten sach: ");String ten =input.nextLine();
            System.out.println("nhap tac gia: "); String tacgia=input.nextLine();
            System.out.println("Nhap nam xuat ban"); String namxb=input.nextLine();
            int check=0;
            System.out.println("chon chuyen nghanh"); check=input.nextInt();
            String chuyennghanh=null;
            if(check == 1){
                chuyennghanh = "Khoa Hoc Tu nhien";
            }
            if(check == 2){
                chuyennghanh = "Van Hoa - Nghe Thhuat";
            }
            if(check == 3){
                chuyennghanh = "Dien Tu Vien Thong";
            }
            if(check == 4){
                chuyennghanh = "Cong Nghe Thong Tin";
            }
            else
            {
                int mas=ListSach.size()+1000;
                s=new Sach(mas,ten,tacgia,namxb,chuyennghanh);
            }
        }catch(Exception e)
        {
            System.out.println("NO!!"+e.getMessage());
        }
        return s;
    }
    public void addS()
    {
        Sach S=newS();
        if(S!=null)
        {
            ListSach.add(S);
        }
    }
     public void showBD()
    {
        System.out.println("Thong tin nguoi doc");
        for(Sach index: ListSach)
        {
            System.out.println(""+index);
        }
    }
}
